    /*var province_area = [];
    function initProvinceArea() {
        var opts = {
            subdistrict: 0,   //获取边界不需要返回下级行政区
            extensions: 'all',  //返回行政区边界坐标组等具体信息
            level: 'province'  //查询行政级别为 市
        };
        var district = new AMap.DistrictSearch(opts);//注意：需要使用插件同步下发功能才能这样直接使用
        district.search('440000', function (status, result) {
            if (status == 'complete') {
                getData(result.districtList[0], "province");
            }
        });
        function getData(data, level) {
            var bounds = data.boundaries;
            console.log(bounds);
            if (bounds) {
                for (var i = 0, l = bounds.length; i < l; i++) {
                    var polygon = new AMap.Polygon({
                        path: bounds[i],
                        isOutline: true,
                        borderWeight: 2,
                        strokeColor: "#009944",
                        strokeOpacity: 1,
                        strokeStyle: 'dashed',
                        fillOpacity: 0.1,
                        fillColor: '#009944',
                        zIndex: 2
                    });
                    province_area.push(polygon);
                }
            }
        }
    }*/
    area_name = ['核心区','管控区','引导区','珠海市','广东省'];
    var province_area = [[109.853945,20.17583],[109.539397,21.112361],[109.767966,21.462275],[109.71089,21.602102],[109.750548,21.692621],[109.875349,21.684856],[109.903418,21.767725],[109.983671,21.934647],[110.347271,21.918656],[110.298884,22.144549],[110.328451,22.204188],[110.432061,22.213835],[110.51095,22.187881],[110.55612,22.212263],[110.624487,22.199995],[110.634878,22.241569],[110.685873,22.314518],[110.680746,22.47553],[110.758383,22.594279],[111.045492,22.66683],[111.045674,22.740909],[111.194353,22.769971],[111.343398,22.987463],[111.318846,23.259737],[111.363127,23.38984],[111.390676,23.482238],[111.46217,23.539324],[111.484308,23.638326],[111.594501,23.665156],[111.600656,23.753997],[111.62329,23.817654],[111.662403,23.871234],[111.785897,23.834339],[111.807666,23.951424],[111.906135,23.979659],[111.853542,24.090658],[111.861374,24.236628],[112.035525,24.369297],[111.966345,24.474332],[111.970809,24.51932],[111.913817,24.619236],[111.93167,24.724062],[112.066252,24.821322],[112.139037,24.856217],[112.151396,24.913523],[112.092345,24.974538],[112.118437,25.060405],[112.184356,25.19717],[112.331298,25.204625],[112.453521,25.192199],[112.68698,25.142482],[112.813323,24.896085],[112.873748,24.923487],[112.973912,24.93594],[112.953227,25.028056],[112.977775,25.07782],[112.949966,25.142482],[112.971252,25.226989],[112.865508,25.222019],[112.818816,25.351157],[113.277495,25.571861],[113.360643,25.479561],[113.463018,25.424405],[113.607342,25.3587],[113.725703,25.400982],[113.797629,25.366436],[113.85359,25.475972],[114.020445,25.476747],[114.07675,25.326954],[114.163268,25.334712],[114.274504,25.339987],[114.551909,25.435518],[114.642546,25.346813],[114.741423,25.310195],[114.775069,25.225591],[114.704344,25.185675],[114.749663,25.17045],[114.757903,25.125076],[114.685118,25.07471],[114.51895,24.977027],[114.411834,24.806364],[114.285491,24.684139],[114.42797,24.55188],[114.531997,24.579435],[114.679626,24.599572],[114.700225,24.554924],[114.730437,24.637962],[114.873259,24.626727],[114.921496,24.678056],[115.057624,24.72188],[115.181563,24.739654],[115.358031,24.800131],[115.458282,24.816336],[115.601791,24.642643],[115.676635,24.626103],[115.721954,24.56804],[115.818084,24.576782],[115.740493,24.680396],[115.750793,24.866186],[115.804351,24.928468],[115.864432,24.915547],[115.877822,24.947459],[116.014464,24.946525],[116.07034,24.876659],[116.126216,24.866575],[116.188529,24.89375],[116.280196,24.828489],[116.408599,24.89484],[116.448424,24.759609],[116.550734,24.660741],[116.647551,24.681644],[116.823332,24.684139],[116.830757,24.549167],[116.882126,24.439057],[116.990359,24.263627],[117.042029,24.152857],[116.969588,24.121683],[117.055418,23.828372],[117.095244,23.723435],[117.207854,23.654268],[117.23532,23.576254],[117.048552,23.22462],[116.565154,22.82903],[114.665758,22.396545],[114.489118,22.437724],[114.472467,22.46874],[114.466631,22.532019],[114.406206,22.599549],[114.308445,22.563034],[114.23403,22.543633],[114.214289,22.553027],[114.166567,22.552789],[114.123308,22.526945],[114.054643,22.50189],[113.882982,22.431457],[113.720934,22.71044],[113.628923,22.212316],[113.584021,22.222374],[113.558119,22.212811],[113.545606,22.211194],[113.54324,22.205734],[113.530794,22.182548],[113.536545,22.169374],[113.553196,22.139843],[113.557659,22.073443],[113.491569,22.055147],[112.86209,21.508538],[110.725249,21.119613],[110.653838,20.307805]];
    var city_area = [[113.16065,22.235562],[113.184854,22.29323],[113.188373,22.33444],[113.150307,22.369963],[113.15874,22.395023],[113.177033,22.403424],[113.18049,22.404731],[113.186339,22.39856],[113.194075,22.379532],[113.207177,22.385583],[113.210723,22.397099],[113.211467,22.401428],[113.219763,22.395918],[113.233465,22.398635],[113.238256,22.390787],[113.253526,22.398291],[113.264766,22.391727],[113.32197,22.328038],[113.320875,22.312382],[113.339468,22.26667],[113.353571,22.245874],[113.380964,22.235554],[113.392257,22.231983],[113.416272,22.200797],[113.430258,22.202139],[113.448237,22.209803],[113.461924,22.218419],[113.484582,22.227035],[113.479946,22.238573],[113.494365,22.242912],[113.503891,22.251754],[113.512732,22.265361],[113.470716,22.305645],[113.473001,22.310314],[113.480436,22.31276],[113.483767,22.316048],[113.498737,22.323408],[113.490257,22.346618],[113.485159,22.379732],[113.484841,22.400095],[113.502621,22.408926],[113.520401,22.412996],[113.57566,22.413425],[113.630326,22.447119],[113.675035,22.446858],[113.659713,22.359349],[113.608965,22.299375],[113.633287,22.236253],[113.589315,22.223116],[113.557544,22.21313],[113.538912,22.209726],[113.54084,22.201588],[113.531333,22.180511],[113.545658,22.151963],[113.55449,22.143126],[113.553616,22.105096],[113.571435,22.080076],[113.56208,22.065918],[113.492171,22.052474],[113.405782,21.974413],[113.323385,21.906422],[113.26708,21.869229],[113.200475,21.852421],[113.136617,21.828838],[113.115331,21.894477],[113.098165,22.106797],[113.102285,22.204415]];
    var core_area = [[113.412854, 22.076612], [113.421609, 22.065874], [113.399293, 22.022118], [113.364145, 21.996208], [113.345606, 22.051905],];
    // var controls_area = [[113.361313, 21.997084], [113.34449, 22.052303], [113.401653, 22.084756], [113.38998, 22.164903], [113.517868, 22.226095], [113.497955, 22.253107], [113.44474, 22.264546], [113.34037, 22.236265], [113.260204, 22.179846], [113.217804, 22.084597], [113.319771, 21.994059]];
    var controls_area = [[113.361313,21.997084],[113.34449,22.052303],[113.401653,22.084756],[113.38998,22.164903],[113.517868,22.226095],[113.506882,22.253186],[113.497268,22.263275],[113.477098,22.273362],[113.451435,22.269471],[113.340027,22.228956],[113.260204,22.179846],[113.217804,22.084597],[113.319771,21.994059]];
    // var guide_area = [[113.548686, 22.211368], [113.560445, 22.216612], [113.587482, 22.248551], [113.595507, 22.314551], [113.586881, 22.357422], [113.552205, 22.366947], [113.143995, 22.229563], [113.120992, 22.16726], [113.154294, 21.985595], [113.19412, 21.983367], [113.221586, 22.108109], [113.249051, 22.176798], [113.436162, 22.279768], [113.523202, 22.271069]];
    var guide_area = [[113.523756,22.230139],[113.533818,22.216145],[113.549029,22.212957],[113.560445,22.216612],[113.587482,22.248551],[113.595507,22.314551],[113.586881,22.357422],[113.552205,22.366947],[113.143995,22.229563],[113.120992,22.16726],[113.154294,21.985595],[113.19412,21.983367],[113.221586,22.108109],[113.249051,22.176798],[113.415391,22.274685],[113.457278,22.27535],[113.479596,22.269978],[113.505693,22.261935]];
    var  today = [], yestoday = [], last_week = [], time_gap = [];
    for(var i=0;i<24;i++){
        for(var j =0;j<2;j++){
            var hour = i<10?('0'+i):(i+'');
            var minute = (j*30)===0?('0'+j*30+''):(j*30+'');
            var time = hour + ':'+ minute;
            time_gap.push(time);
            today.push(0);
            yestoday.push(0);
            last_week.push(0);
        }
    }
    //区域选择 [核心区，管控区，引导区]
    var area_select = [core_area, controls_area, guide_area,city_area,province_area];
    var car_color = ["images/bus/hong_bus.png", "images/bus/qing_bus.png", "images/bus/lan_bus.png", "images/greenCar.png", "images/bus/huang_bus.png","images/bus/zi_bus.png"];
    // var taxi, bus, boBus, travleBus, specialBus;
    var car_core_area = [0, 0, 0, 0, 0, 0];
    var car_controls_area = [0, 0, 0, 0, 0, 0];
    var car_guide_area = [0, 0, 0, 0, 0, 0];
    var car_city_area = [0, 0, 0, 0, 0, 0];
    var car_province_area = [0, 0, 0, 0, 0, 0];
    var car_count_area = null;
    //
    // var specialBus_sum = [0, 0, 0, 0], boBus_sum = [0, 0, 0, 0], travelBus_sum = [0, 0, 0, 0], taxi_sum = [0, 0, 0, 0],
    //     bus_sum = [0, 0, 0, 0];
    // var car_sum_list = [specialBus_sum, boBus_sum, travelBus_sum, taxi_sum, bus_sum];
    //专线，接驳巴士，旅游大巴，出租车，公交车
    var specialBusList = [], boBusList = [], travelBusList = [], taxiList = [], busList = [],turnBusList=[];
    var list_array = [specialBusList, boBusList, travelBusList, taxiList, busList,turnBusList];
    var car_id = ["#specialSum", "#boBusSum", "#travelBusSum", "#taxiSum", "#busSum","#turnBusSum"];
    var bar_id = ["#special_bar", "#boBus_bar", "#travelBus_bar", "#taxi_bar", "#bus_bar","#turnBus_bar"];
    var specialBus_markers = {}, boBus_markers = {}, travelBus_markers = {}, taxi_markers = {}, bus_markers = {} ,turnBus_markers={};
    var create_flag = false;
    var current_area_id = 0;
    var current_car_id = "";
    //car
    var car_list_core_area = [{}, {}, {}, {}, {},{}], car_list_controls_area = [{}, {}, {}, {}, {},{}],
        car_list_guide_area = [{}, {}, {}, {}, {},{}], car_list_city_area = [{}, {}, {}, {}, {},{}],
        car_list_province_area = [{}, {}, {}, {}, {},{}];
    var car_list = [car_list_core_area, car_list_controls_area, car_list_guide_area,car_list_city_area,car_list_province_area];
    //marker

    var marker_core_area = [{}, {}, {}, {}, {},{}],
        marker_controls_area = [{}, {}, {}, {}, {},{}],
        marker_guide_area = [{}, {}, {}, {}, {},{}],
        marker_city_area = [{}, {}, {}, {}, {},{}];
        marker_province_area = [{}, {}, {}, {}, {},{}];

    //当前区域
    var total_markers = [specialBus_markers, boBus_markers, travelBus_markers, taxi_markers, bus_markers,turnBus_markers];
    var region_markers = [{}, {}, {}, {}, {},{}];
    var show_points = [{}, {}, {}, {}, {},{}];

    var region_poiints = [[{},{},{},{},{},{}],[{},{},{},{},{},{}],[{},{},{},{},{},{}],[{},{},{},{},{},{}],[{},{},{},{},{},{}]];
    airShowArea = {
        markers: [marker_core_area, marker_controls_area, marker_guide_area,marker_city_area,marker_province_area],
        map: null,
        chart: null,
        polygon: null,
        init: function () {
            // initProvinceArea();
            initMap();
            initChart();
        }
    };

    // 初始化地图
    var initMap = function () {
        airShowArea.map = new AMap.Map('container', {
            resizeEnable: true, //是否监控地图容器尺寸变化
            // mapStyle: "amap://styles/macaron",
            center: [113.58397428, 22.2790923]//中心点坐标
        });
        //获取点,展示点
        init_marker = false;
        getMaker();
        setInterval(getMaker, 1000 * 10);

        //创建区域，默认核心区域
        createArea(0);
        // 缩放地图到合适的视野级别
        airShowArea.map.setFitView([airShowArea.polygon]);

    };

    // 显示车
    // var showMarkers = function () {
    //     console.log("showMarkers......");
    //     for (var a in airShowArea.markers) {//012
    //         var list = airShowArea.markers[a];
    //         if(list) {
    //             for (var l in list) {//01234
    //                 var carList = list[l];
    //                 for (var c in carList) {
    //                     var car = carList[c];
    //                     if (car !== null) {
    //                         carList[c].setMap(null);
    //                     }
    //                 }
    //             }
    //         }
    //     }
    //     region_markers = airShowArea.markers[current_area_id];
    //     if (car_select) {
    //         for (var a in car_select) {
    //             var list = region_markers[Number(car_select[a])-1];
    //             if(list) {
    //                 for (var l in list) {
    //                     if (list[l] !== null) {
    //                         list[l].setMap(airShowArea.map);
    //                     }
    //                 }
    //             }
    //         }
    //     }
    //     //选择区域
    //     /*
    //     region_markers = airShowArea.markers[current_area_id];//012
    //     if (current_car_id === -1 || current_car_id === "") {
    //         for (var a in region_markers) {
    //             var list = region_markers[a];//01234
    //             if(list) {
    //                 for (var l in list) {
    //                     if (list[l] !== null) {
    //                         list[l].setMap(airShowArea.map);
    //                     }
    //                 }
    //             }
    //         }
    //     } else {
    //         var list = region_markers[current_car_id];
    //         for (var l in list) {
    //             if(list[l]!== null) {
    //                 list[l].setMap(airShowArea.map);
    //             }
    //         }
    //     }*/
    // }

    // 更新数据
    var updateSumAndBar = function () {
        var len = 0;
        for(var c in car_count_area[current_area_id]){
            len+=car_count_area[current_area_id][c];
        }
        for (var a in list_array) {
            var list = list_array[a];
            if (list&&list.length > 0) {
                $(car_id[a]).html(car_count_area[current_area_id][a]);
                var percent = (Math.round(car_count_area[current_area_id][a] / len * 10000) / 100.00) + "%";
                $(bar_id[a]).width(percent);
            }
        }
    };


    // function compute_init(obj, n) {
    //     var position = [Number(obj.lon), Number(obj.lat)];
    //     var isPointInRing1 = AMap.GeometryUtil.isPointInRing(position, core_area);
    //     if (isPointInRing1 === true) {
    //         car_list_core_area[n][obj.id] = obj;
    //         car_core_area[n]++;
    //     }
    //     /*
    //     else {
    //         //车辆离开区域
    //         if (typeof car_list_core_area[n][obj.id] !== 'undefined') {
    //             console.log(n+"-"+obj.id+"车子离开核心区");
    //             var speed;
    //             if (n === 0) {
    //                 speed = (typeof obj.vat === 'undefined' ? 30 : obj.vat);
    //             } else {
    //                 speed = (typeof obj.vec1 === 'undefined' ? 30 : obj.vec1);
    //             }
    //             airShowArea.markers[0][n][obj.id].moveTo([obj.lon, obj.lat], speed);
    //             if (total_markers[n][obj.od]) {
    //                 console.log("地图车辆-1");
    //                 total_markers[n][obj.id].setMap(null);
    //             }
    //             car_list_core_area[n][obj.id] = null;
    //             car_core_area[n]--;
    //         }
    //     }*/
    //     var isPointInRing2 = AMap.GeometryUtil.isPointInRing(position, controls_area);
    //     if (isPointInRing2 === true) {
    //         car_list_controls_area[n][obj.id] = obj;
    //         car_controls_area[n]++;
    //     }
    //     /*else {
    //      if (typeof car_list_controls_area[n][obj.id] !== 'undefined') {
    //      var speed;
    //      if (l === 0) {
    //      speed = (typeof car.vat === 'undefined' ? 10 : car.vat);
    //      } else {
    //      speed = (typeof car.vec1 === 'undefined' ? 10 : car.vec1);
    //      }
    //      airShowArea.markers[1][n][obj.id].moveTo([obj.lon, obj.lat], speed);
    //      car_list_controls_area[n][obj.id] = null;
    //      }
    //      }*/
    //     var isPointInRing3 = AMap.GeometryUtil.isPointInRing(position, guide_area);
    //     if (isPointInRing3 === true) {
    //         car_list_guide_area[n][obj.id] = obj;
    //         car_guide_area[n]++;
    //     }
    //     /*else {
    //      if (typeof car_list_guide_area[n][obj.id] !== 'undefined') {
    //      var speed;
    //      if (l === 0) {
    //      speed = (typeof car.vat === 'undefined' ? 10 : car.vat);
    //      } else {
    //      speed = (typeof car.vec1 === 'undefined' ? 10 : car.vec1);
    //      }
    //      airShowArea.markers[2][n][obj.id].moveTo([obj.lon, obj.lat], speed);
    //      car_list_guide_area[n][obj.id] = null;
    //      }
    //      }*/
    //     // car_list_province_area[n][obj.id] = obj;
    //     // car_province_area[n]++;
    //     var isPointInRing4 = AMap.GeometryUtil.isPointInRing(position, city_area);
    //     if (isPointInRing4 === true) {
    //         car_list_city_area[n][obj.id] = obj;
    //         car_city_area[n]++;
    //     }
    //     var isPointInRing5 = AMap.GeometryUtil.isPointInRing(position, province_area);
    //     if (isPointInRing5 === true) {
    //         car_list_province_area[n][obj.id] = obj;
    //         car_province_area[n]++;
    //     }
    // }


    // 绘制区域
    var createArea = function (val) {
        airShowArea.polygon = new AMap.Polygon({
            path: area_select[val],
            isOutline: true,
            borderWeight: 2,
            strokeColor: "#009944",
            strokeOpacity: 1,
            strokeStyle: 'dashed',
            fillOpacity: 0.1,
            fillColor: '#009944',
            zIndex: 2
        });
        airShowArea.polygon.setMap(airShowArea.map);
    };

    // 获取车
    var getMaker = function () {
        var url = "getGps.do";
        $.ajax({
            url: url,
            type: "GET",
            async: false,
            success: function (result) {
                specialBusList = result.data.specialList;
                boBusList = result.data.boBusList;
                travelBusList = result.data.travelBusList;
                busList = result.data.busList;
                taxiList = result.data.taxiList;
                turnBusList = result.data.turnBusList;
                list_array[0] = specialBusList;
                list_array[1] = boBusList;
                list_array[2] = travelBusList;
                list_array[3] = taxiList;
                list_array[4] = busList;
                list_array[5] = turnBusList;

                initRegionPoint();
                if(!init_marker){
                    region_markers = [{}, {}, {}, {}, {},{}];
                    initMarker2();
                    init_marker = true;
                }else {
                    updateMarker2();
                }
                showMarkers2();
                updateSumAndBar();

                // car_core_area = [0, 0, 0, 0, 0];
                // car_controls_area = [0, 0, 0, 0, 0];
                // car_guide_area = [0, 0, 0, 0, 0];
                // car_city_area = [0,0,0,0,0];
                // car_province_area = [0,0,0,0,0];
                /*
                if (!create_flag) {
                    initRegionMarker();
                    create_flag = true;
                } else {
                    updateMakers();
                }
                showMarkers();
                updateSumAndBar();
                */
            }
        })
    };
    var updateMarker2 = function () {
        for (var a in show_points) {
            var list = show_points[a];
            if (list) {
                for (var l in list) {
                    var obj = list[l];
                    var speed;
                    if (obj.vat) {
                        speed = (typeof obj.vat === 'undefined' ? 30 : obj.vat);
                    } else {
                        speed = (typeof obj.vec1 === 'undefined' ? 30 : obj.vec1);
                    }
                    var position = [Number(obj.lon), Number(obj.lat)];
                    if (!region_markers[a][obj.id]) {
                        var maker = new AMap.Marker({
                            position: position,
                            offset: new AMap.Pixel(-10, -10),
                            icon: car_color[a],
                            angle: Number(obj.direction) + 90,
                            autoRotation: true,
                            extData: obj
                        });
                        region_markers[a][obj.id] = maker;
                    } else {
                        region_markers[a][obj.id].moveTo(position, speed > 30 ? speed*3 : 100);
                    }
                }
            }
        }
        // 车子离开区域
        for(var r in region_markers){
            var list = region_markers[r];
            if(list){
                for(var l in list){
                    if(!show_points[r][l]){
                        region_markers[r][l].setMap(null);
                    }
                }
            }
        }
    }
    var showMarkers2 = function () {
        for(var a in region_markers){
            var list = region_markers[a];
            if(list) {
                for (var l in list) {
                    if (list[l] !== null) {
                        list[l].setMap(null);
                    }
                }
            }
        }
        if(car_select){
            for(var a in car_select){
                var list = region_markers[Number(car_select[a])-1];
                if(list) {
                    for (var l in list) {
                        if (list[l] !== null) {
                            list[l].setMap(airShowArea.map);
                        }
                    }
                }
            }
        }
    }
    var initMarker2 = function () {
        console.log("showMarkers......");
        show_points = region_poiints[current_area_id];
        for(var a in show_points){
            var list = show_points[a];
            if(list){
                for(var l in list){
                    var obj = list[l];
                    var position = [Number(obj.lon),Number(obj.lat)];
                    var maker = new AMap.Marker({
                        position: position,
                        offset: new AMap.Pixel(-10, -10),
                        icon: car_color[a],
                        angle: Number(obj.direction) + 90,
                        autoRotation: true,
                        extData: obj
                    });
                    region_markers[a][obj.id] = maker;
                }
            }
        }
    }
    var initRegionPoint = function () {
        car_count_area = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]];
        for(var a in list_array){
            var list = list_array[a];
            if(list){
                for(var b in list){
                    var obj = list[b];
                    var position = [Number(obj.lon),Number(obj.lat)];
                    for(var c in area_select){
                        var isPointInRing = AMap.GeometryUtil.isPointInRing(position, area_select[c]);
                        if(isPointInRing){
                            region_poiints[c][a][obj.id] = obj;
                            car_count_area[c][a]++;
                        }
                    }
                }
            }
        }
    }
/*
    // 初始化区域
    var initRegionMarker = function () {
        console.log("initRegionMakers...");
        // car_list_core_area = [{}, {}, {}, {}, {}], car_list_controls_area = [{}, {}, {}, {}, {}], car_list_guide_area = [{}, {}, {}, {}, {}],car_list_province_area = [{}, {}, {}, {}, {}];;
        fillListArray();
        createMarker();
    };

    var fillListArray = function () {
        // car_core_area = [0, 0, 0, 0, 0], car_controls_area = [0, 0, 0, 0, 0], car_guide_area = [0, 0, 0, 0, 0],car_province_area = [0, 0, 0, 0, 0];
        for (var a in list_array) {//01234
            var list = list_array[a];
            if (list&&list.length > 0) {
                for (var l in list) {
                    var obj = list[l];
                    compute_init(obj, a);
                }
            }
        }
        car_count_area = [car_core_area, car_controls_area, car_guide_area,car_city_area,car_province_area];
        car_list = [car_list_core_area, car_list_controls_area, car_list_guide_area,car_list_city_area,car_list_province_area];
    }

    // 更新车
    var updateMakers = function () {
        // car_list_core_area = [], car_list_controls_area = [], car_list_guide_area = [];
        console.log("updateMakers...");
        // fillListArray();
        // updateMarker();
        for(var a in list_array){//后台传过来的GPS数据
            var list = list_array[a];//车种  01234
            if(list){
                for(var l in list){
                    var obj = list[l];//100+   1000   1000
                    var speed;
                    if (a === 0) {
                        speed = (typeof obj.vat === 'undefined' ? 30 : obj.vat);
                    } else {
                        speed = (typeof obj.vec1 === 'undefined' ? 30 : obj.vec1);
                    }
                    var position = [Number(obj.lon),Number(obj.lat)];
                    for(var c in area_select){
                        var isPointInRing = AMap.GeometryUtil.isPointInRing(position, area_select[c]);
                        if(isPointInRing){
                            if(airShowArea.markers[c][a][obj.id]){
                                airShowArea.markers[c][a][obj.id].moveTo(position,(speed>30?speed*3:100));
                            }else {
                                console.log("有车子进入"+area_name[c]);
                                var maker = new AMap.Marker({
                                    position: position,
                                    offset: new AMap.Pixel(-10, -10),
                                    icon: car_color[a],
                                    angle: Number(obj.direction) + 90,
                                    autoRotation: true,
                                    extData: obj
                                });
                                airShowArea.markers[c][a][obj.id] = maker;
                                car_count_area[c][a]++;
                            }
                        }else{
                            if(airShowArea.markers[c][a][obj.id]){
                                console.log("有车子离开"+area_name[c]);
                                airShowArea.markers[c][a][obj.id].setMap(null);
                                delete airShowArea.markers[c][a][obj.id];
                                car_count_area[c][a]--;
                            }
                        }
                    }
                    /*
                    // for(var t in total_markers[a]){//对应车种的所有marker   100+  1000  1000
                    //判断在那个区域
                    console.log("开始卡。。。");
                    var position = [Number(obj.lon),Number(obj.lat)];
                    var isPointInRing1 = AMap.GeometryUtil.isPointInRing(position, core_area);
                    var isPointInRing2 = AMap.GeometryUtil.isPointInRing(position, controls_area);
                    var isPointInRing3 = AMap.GeometryUtil.isPointInRing(position, guide_area);

                    var isPointInRing4 = AMap.GeometryUtil.isPointInRing(position, city_area);
                    if(isPointInRing4){
                        if(marker_city_area[a][obj.id]){
                            marker_city_area[a][obj.id].moveTo(position,(speed>30?speed*3:100));
                        }else {
                            console.log("有车子进入珠海市");
                            var maker = new AMap.Marker({
                                position: position,
                                offset: new AMap.Pixel(-10, -10),
                                icon: car_color[a],
                                angle: Number(obj.direction) + 90,
                                autoRotation: true,
                                extData: obj
                            });
                            marker_city_area[a][obj.id] = maker;
                            car_city_area[a]++;
                        }
                    }else{
                        if(marker_city_area[a][obj.id]){
                            console.log("有车子离开珠海市");
                            delete marker_city_area[a][obj.id];
                            car_city_area[a]--;
                        }
                    }
                    var isPointInRing5 = AMap.GeometryUtil.isPointInRing(position, province_area);
                    if(isPointInRing5) {
                        if (marker_province_area[a][obj.id]) {
                            marker_province_area[a][obj.id].moveTo(position, (speed > 30 ? speed * 3 : 100));
                        } else {
                            console.log("有车子进入珠海市");
                            var maker = new AMap.Marker({
                                position: position,
                                offset: new AMap.Pixel(-10, -10),
                                icon: car_color[a],
                                angle: Number(obj.direction) + 90,
                                autoRotation: true,
                                extData: obj
                            });
                            marker_province_area[a][obj.id] = maker;
                        }
                    }

                    if(isPointInRing1===true){
                        //是否之前就在区域1内
                        if(marker_core_area[a][obj.id]){
                            marker_core_area[a][obj.id].moveTo(position,(speed>30?speed*3:100));
                        }else {
                            //新增点在区域1内
                            var maker = new AMap.Marker({
                                position: position,
                                offset: new AMap.Pixel(-10, -10),
                                icon: car_color[a],
                                angle: Number(obj.direction) + 90,
                                autoRotation: true,
                                extData: obj
                            });
                            marker_core_area[a][obj.id] = maker;
                        }
                        //从区域2或区域3过来的
                        if(marker_controls_area[a][obj.id]){
                            marker_controls_area[a][obj.id].setMap(null);
                            delete marker_controls_area[a][obj.id];
                        }
                        if(marker_guide_area[a][obj.id]){
                            marker_guide_area[a][obj.id].setMap(null);
                            delete  marker_guide_area[a][obj.id];
                        }
                    }else if(isPointInRing2===true){
                        //是否之前就在区域2内
                        if(marker_controls_area[a][obj.id]){
                            marker_controls_area[a][obj.id].moveTo(position,(speed>30?speed*3:100));
                        }else {
                            //新增点在区域2内
                            var maker = new AMap.Marker({
                                position: position,
                                offset: new AMap.Pixel(-10, -10),
                                icon: car_color[a],
                                angle: Number(obj.direction) + 90,
                                autoRotation: true,
                                extData: obj
                            });
                            marker_controls_area[a][obj.id] = maker;
                        }
                        //从区域1或区域3过来的
                        if(marker_core_area[a][obj.id]){
                            marker_core_area[a][obj.id].setMap(null);
                            delete  marker_core_area[a][obj.id];
                        }
                        if(marker_guide_area[a][obj.id]){
                            marker_guide_area[a][obj.id].setMap(null);
                            delete  marker_guide_area[a][obj.id];
                        }
                    }else if(isPointInRing3===true){
                        //是否之前就在区域3内
                        if(marker_guide_area[a][obj.id]){
                            marker_guide_area[a][obj.id].moveTo(position,(speed>30?speed*3:100));
                        }else {
                            //新增点在区域3内
                            var maker = new AMap.Marker({
                                position: position,
                                offset: new AMap.Pixel(-10, -10),
                                icon: car_color[a],
                                angle: Number(obj.direction) + 90,
                                autoRotation: true,
                                extData: obj
                            });
                            marker_guide_area[a][obj.id] = maker;
                        }
                        //从区域1或区域2过来的
                        if(marker_core_area[a][obj.id]){
                            marker_core_area[a][obj.id].setMap(null);
                            delete  marker_core_area[a][obj.id];
                        }
                        if(marker_controls_area[a][obj.id]){
                            marker_controls_area[a][obj.id].setMap(null);
                            delete  marker_controls_area[a][obj.id];
                        }
                    }else if(!(isPointInRing1||isPointInRing2||isPointInRing3)){
                        //不在3个区域内
                        if(marker_core_area[a][obj.id]){
                            marker_core_area[a][obj.id].setMap(null);
                            delete  marker_core_area[a][obj.id];
                        }
                        if(marker_controls_area[a][obj.id]){
                            marker_controls_area[a][obj.id].setMap(null);
                            delete  marker_controls_area[a][obj.id];
                        }
                        if(marker_guide_area[a][obj.id]){
                            marker_guide_area[a][obj.id].setMap(null);
                            delete  marker_guide_area[a][obj.id];
                        }
                    }
                    // }
                    *//*
                }
            }
        }
        // airShowArea.markers = [marker_core_area, marker_controls_area, marker_guide_area,marker_city_area,marker_province_area];
        console.log("结束卡。。。");
        for(var a in airShowArea.markers){
            console.log(airShowArea.markers[a]);
        }
    }*/

    // 初始化出租车图表
    var initChart = function () {
        airShowArea.chart = echarts.init(document.getElementById('taxiChart'));
        airShowArea.chart.setOption(getEchartOption());
        setInterval(function () {
            airShowArea.chart.setOption(getEchartOption());
            console.log("updateChart...")
        }, 1000 * 60 * 10);
    };

    var getIndex = function (data) {
        var a = data.recordDate;
        var time = Date.parse(a);
        var dt = new Date(time);
        var str = dt.getHours()+":"+dt.getMinutes();
        var index = 2*dt.getHours();
        if(dt.getMinutes()>=30){
            index++;
        }
        return index;
    }
    var getEchartOption = function () {
        var url = "getTaxiTrend.do";
        $.ajax({
            url: url,
            type: "GET",
            async: false,
            success: function (result) {
                var recordList1 = result.data.recordList1;
                var recordList2 = result.data.recordList2;
                var recordList3 = result.data.recordList3;
                for (var i in recordList1) {
                    var index = getIndex(recordList1[i]);
                    today[index] = recordList1[i].carSum;
                }
                for (var j in recordList2) {
                    var index = getIndex(recordList2[j]);
                    yestoday[index] = recordList2[j].carSum;
                }
                for (var k in recordList3) {
                    var index = getIndex(recordList3[k]);
                    last_week[index] = recordList3[k].carSum;
                }
            }
        });
        var option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow',
                    shadowStyle: {
                        color: new echarts.graphic.LinearGradient(
                            0, 0, 0, 1,
                            [
                                {offset: 0, color: 'rgba(255,255,255,.1)'},
                                {offset: 1, color: 'rgba(255,255,255,0)'}
                            ], false)
                    }
                },
                formatter: function (a) {
                    var date = a[0].axisValue,
                        dateNext = moment(moment().format("YYYY-MM-DD")+" "+date).add(30,'minutes').format("HH:mm");
                    var tipHtml = '<div class="chart-tip"><span>' + date + " - " + dateNext + '</span>';
                    for (var i = 0; i < a.length; i++) {
                        tipHtml += '<p>' + a[i].seriesName + '： ' + a[i].value + ' 辆</p>';
                    }
                    tipHtml += '</div>';
                    return tipHtml
                },
                backgroundColor: 'transparent',
                padding: 0
            },
            legend: {
                show: false
            },
            grid: {
                show: true,
                left: 0,
                right: 0,
                bottom: 0,
                top: 10,
                containLabel: true,
                backgroundColor: 'rgba(0,0,0,0.2)',
                borderWidth: 0
            },
            xAxis: {
                type: 'category',
                data: time_gap,
                axisTick: {
                    show: false
                },
                axisLabel: {
                    fontSize: 14,
                    color: '#ffffff'
                },
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#236386'
                    }
                },
                splitLine: {
                    show: false
                }
            },
            yAxis: {
                type: 'value',
                axisTick: {
                    show: false
                },
                axisLabel: {
                    fontSize: 12,
                    color: '#95a9bb'
                },
                axisLine: {
                    show: false
                },
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#236386'
                    }
                }
            },
            series: [{
                name: '今日车数',
                // name: '十月十一日',
                type: 'line',
                data: today,
                areaStyle: {
                    color: '#fff79c',
                    opacity: 0.5
                },
                symbolSize: 5,
                itemStyle: {
                    color: '#fff79c',
                    borderColor: '#fff79c',
                    borderWidth: 2
                },
                lineStyle: {
                    color: '#fff79c',
                    width: 2
                },
                zlevel: 10
            },
                {
                    name: '昨日车数',
                    // name: '十月十日',
                    type: 'line',
                    data: yestoday,
                    itemStyle: {
                        color: '#e5ebee',
                        borderColor: '#e5ebee',
                        borderWidth: 2,
                        opacity: 0
                    },
                    lineStyle: {
                        color: '#e5ebee',
                        width: 2
                    },
                    zlevel: 5
                },
                {
                    name: '上周车数',
                    // name: '十月九日',
                    type: 'line',
                    data: last_week,
                    itemStyle: {
                        color: 'rgba(229,235,238,0.3)',
                        borderColor: 'rgba(229,235,238,0.3)',
                        borderWidth: 2,
                        opacity: 0
                    },
                    lineStyle: {
                        color: 'rgba(229,235,238,0.3)',
                        width: 2
                    },
                    zlevel: 1
                }
            ]
        };
        return option;
    };

    // 图表自适应浏览器尺寸
    window.onresize = function () {
        airShowArea.chart.resize();
    };

    var clear_region_markers = function () {
        for(var a in region_markers){
            var list = region_markers[a];
            if(list) {
                for (var l in list) {
                    if (list[l] !== null) {
                        list[l].setMap(null);
                    }
                }
            }
        }
    }
/*
    function createMarker() {
        for (var c in car_list) {//012
            var list_array = car_list[c];
            for (var l in list_array) {//01234
                var list = list_array[l];
                if(list!==null) {
                    for (var o in list) {//obj.id
                        var car = list[o];
                        var maker = new AMap.Marker({
                            position: [car.lon, car.lat],
                            offset: new AMap.Pixel(-10, -10),
                            icon: car_color[l],
                            angle: Number(car.direction) + 90,
                            autoRotation: true,
                            extData: car
                        });
                        total_markers[l][o] = maker;
                        if (c === "0") {
                            marker_core_area[l][o] = maker;
                        } else if (c === "1") {
                            marker_controls_area[l][o] = maker;
                        } else if (c === "2") {
                            marker_guide_area[l][o] = maker;
                        }else if(c === '3'){
                            marker_city_area[l][o] = maker;
                        }else if(c === '4'){
                            marker_province_area[l][o] = maker;
                        }
                    }
                }
            }
        }
        airShowArea.markers = [marker_core_area, marker_controls_area, marker_guide_area,marker_city_area,marker_province_area];
        console.log(airShowArea.markers);
        console.log(total_markers);
    }

    function updateMarker() {
        console.log("更新点。。。。。。。。。。。");
        for (var c in car_list) {//012
            var list_array = car_list[c];
            for (var l in list_array) {//01234
                var list = list_array[l];
                if(list!==null) {
                    for (var o in list) {//obj.id
                        var car = list[o];
                        if (car !== null) {
                            var position = [car.lon, car.lat];
                            //车辆进入区域

                            if (typeof total_markers[l][o] === 'undefined') {
                                console.log("区域新增点。。。。");
                                console.log(l + "-" + o);
                                var maker = new AMap.Marker({
                                    position: [car.lon, car.lat],
                                    offset: new AMap.Pixel(-10, -10),
                                    icon: car_color[l],
                                    angle: Number(car.direction) + 90,
                                    autoRotation: true,
                                    extData: car
                                });
                                total_markers[l][o] = maker;
                            }
                            //todo 采用了固定速度 30m/s
                            var speed;
                            if (l === 0) {
                                speed = (typeof car.vat === 'undefined' ? 30 : car.vat);
                            } else {
                                speed = (typeof car.vec1 === 'undefined' ? 30 : car.vec1);
                            }
                            // airShowArea.markers[c][l][o].moveTo(position, speed>30?speed:30);
                            total_markers[l][o].moveTo(position, speed > 30 ? speed : 30);
                            // todo 车辆离开区域 效果未知，不行就只能让他直接消失
                        }
                    }
                }
            }
        }
        console.log(total_markers);
    }
    */

